package com.briup.jz.web.controller;

import com.briup.jz.service.ICheckService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program：jz
 * @description：审核
 * @author：axin
 * @create：Created in 2020/6/15 17:08
 */
@RestController
@RequestMapping("/check")
@Api(description = "审核管理接口")
public class CheckController {
    @Autowired
    private ICheckService checkService;

    @ApiOperation(value = "通过状态查询所有用户")
    @GetMapping("findAllByStatus")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status" ,value = "用户状态",required = true, paramType = "query")
    })
    public Message findAllByStatus(String status){
        return MessageUtil.success(checkService.findAllByStatus(status));
    }

    @ApiOperation(value = "修改用户状态")
    @PostMapping("updateUserStatus")
    public Message updateUserStatus(Long id, String status){
        checkService.updateUserStatus(id,status);
        return MessageUtil.success("更新成功");
    }

    @ApiOperation(value = "提现余额检查")
    @GetMapping("withDrawal")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id" ,value = "唯一编号", required = true, paramType = "query")
    })
    public Message withDarwal(Long id, Long money){
        if(checkService.withDarwal(id,money)==true){
            return MessageUtil.success("余额充足，可以提现");
        }else{
            return MessageUtil.error("余额不足，不允许提现");
        }

    }
}
